package com.boot.security.server.dao.record;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.record.TswWithdrawalRecord;

@Mapper
public interface TswWithdrawalRecordDao {

    @Select("select * from tsw_withdrawal_record t where t.id = #{id}")
    TswWithdrawalRecord getById(Long id);

    @Delete("delete from tsw_withdrawal_record where id = #{id}")
    int delete(Long id);

    int update(TswWithdrawalRecord tswWithdrawalRecord);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_withdrawal_record(user_id, card_id, withdrawal_time, withdrawal_price, poundage, actual_receipt, withdrawal_state, cancel_time, processing_time, sys_user_id, arrive_time, withdrawal_note, withdrawal_remark) values(#{userId}, #{cardId}, #{withdrawalTime}, #{withdrawalPrice}, #{poundage}, #{actualReceipt}, #{withdrawalState}, #{cancelTime}, #{processingTime}, #{sysUserId}, #{arriveTime}, #{withdrawalNote}, #{withdrawalRemark})")
    int save(TswWithdrawalRecord tswWithdrawalRecord);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswWithdrawalRecord> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
